<!--
* description: 公司客户信息编辑
* author: dxuem
* createdDate: 2019-10-22
-->
<template>
  <div class="app-container app-container-table">
    <crmGroupSubmit :formSubmitButton="formSubmitButton" />
    <el-form class="changeOwner filter-params-crm-scroll crm-s-scroll">
      <!-- 基本信息 -->
      <div class="filter-container-crm filter-title-crm">{{infoComponents[0].title}}</div>
      <div class="filter-container-crm filter-params-crm">
        <crmGroupForm :dynamicComponentss="infoComponents[0].tableComponents" :values="formField" ref="ref1"/>
        <crmGroupForm :dynamicComponentss="infoComponents[1].tableComponents" :values="formField" />
        <crmGroupForm :dynamicComponentss="infoComponents[2].tableComponents" :values="formField" />
        <crmGroupForm :dynamicComponentss="infoComponents[3].tableComponents" :values="formField" />
        <crmGroupForm :dynamicComponentss="infoComponents[4].tableComponents" v-show="!(infoComponents[4].isShow==false)" ref="upLoad" :values="formField" />
      </div>
      <!-- 联系信息 -->
      <div class="filter-container-crm filter-title-crm">{{infoComponents[5].title}}</div>
      <div class="filter-container-crm filter-params">
        <crmGroupForm :dynamicComponentss="infoComponents[5].tableComponents" :values="formField" ref="ref2"/>
      </div>
    </el-form>
  </div>
</template>
<script>
import { formMixins } from "@/components/mixins/formMixins";
import { oneTableTemplateMixins } from "@/components/mixins/oneTableTemplateMixins";
import { crmApis } from "@/api/apiList/crm";
import { requestAPI } from "@/api/commonRequest";
import crmGroupForm from "@/components/crm/commonComponents/crmGroupForm";
import crmGroupSubmit from "@/components/crm/commonComponents/crmGroupSubmit";
//import OneTableTemplate from "@/components/crm/table/crmOnetable";
import OneTableTemplate from "@/components/crm/Template/crmonePage";
export default {
  name: "editPer",
  // 组件混入对象
  mixins: [formMixins],
  components: {
    crmGroupForm,
    crmGroupSubmit,
    OneTableTemplate
  },
  props: {},
  data() {
    return {
      State: "",
      ismore: false,
      ismutiple: false,
      action: "", //证件上传地址
      accepttype:
        ".jpg,.jpeg,.png,.gif,.bmp,.pdf,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF", //上传文件类型
      text1: "选择文件",
      limit: 1,
      params: {},
      nagflag: true,
      posflag: false,
      flag: true,
      infoComponents: [
        //基本信息 0
        {
          title: "基本信息",
          tableComponents: [
            {
              compKey: "compKey1",
              labelName: "UID",
              codeField: "uid",
              code: "",
              // isRequire: true,
              disabled: true,
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey2",
              labelName: "公司简称",
              codeField: "custName",
              isRequire: true,
              disabled:
                this.$route.params.status == "edit"&&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey3",
              span: 12,
              labelName: "公司全称",
              codeField: "custFullName",
              isMul: false,
              isRequire: true,
              disabled:
                this.$route.params.status == "edit"&&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            }
          ]
        },
        // 1
        {
          tableComponents: [
            {
              compKey: "compKey4",
              labelName: "机构代码",
              codeField: "credNo",
              isRequire: false,
              isMust: true,
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey5",
              labelName: "法人名称",
              codeField: "legalName",
              isRequire: false,
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey6",
              labelName: "法人电话",
              codeField: "legalPhone",
              isRequire: true,
              validrule: {
                noRequire: true,
                isformat: /^((0\d{2,3}-\d{7,8})|(1(3|4|5|6|7|8|9)\d{9}))$/
              },
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey7",
              labelName: "法人身份证",
              codeField: "legalCredNo",
              isRequire: true,
              validrule: {
                noRequire: true,
                isformat: /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/
              },
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey18",
              labelName: "省份",
              codeField: "provinceId",
              textField: "provinceName",
              isRequire: this.$route.params.status == "edit" && this.$route.params.isCarowner == "是"?false:true,
              isMust: true,
              disabled: this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是" ? true : false,
              isMul: false,
              lookuptype: crmApis.mdmOrgProvinceQueryFindAll,
              component: () =>
                import("@/components/crm/lookupValue/singleDropList")
            },
            {
              compKey: "provinceId",
              labelName: "城市",
              codeField: "cityId",
              textField: "cityName",
              isRequire: this.$route.params.status == "edit" && this.$route.params.isCarowner == "是"?false:true,
              isMust: true,
              isMul: false,
              disabled: this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是" ? true : false,
              lookuptype: crmApis.mdmOrgCityQueryFindAll,
              changeCodeArray: [{ changCode: "provinceId" }],
              component: () =>
                import("@/components/crm/lookupValue/secondDropList")
            },
            {
              compKey: "cityId",
              labelName: "区县",
              codeField: "countyId",
              textField: "countyName",
              isRequire: false,
              isMust: true,
              disabled: this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是" ? true : false,
              isMul: false,
              lookuptype: crmApis.mdmOrgCommunityQueryFindAll,
              changeCodeArray: [{ changCode: "cityId" }],
              component: () =>
                import("@/components/crm/lookupValue/secondDropList")
            }
          ]
        },
        // 2
        {
          tableComponents: [
            {
              compKey: "compKey8",
              labelName: "详细地址",
              span: 12,
              codeField: "addrStreet",
              isRequire: false,
              isMust: true,
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey9",
              labelName: "公司规模",
              codeField: "compOrgscaleCode",
              isRequire: false,
              isMust: true,
              isMul: false,
              lookuptype: "DB0033",
              component: () =>
                import("@/components/crm/lookupValue/lookupvalue")
            },
            {
              compKey: "compKey10",
              labelName: "公司性质",
              codeField: "compKindCode",
              isRequire: false,
              isMust: true,
              disabled: false,
              lookuptype: "DB0038",
              component: () =>
                import("@/components/crm/lookupValue/lookupvalue")
            }
          ]
        },
        //  3
        {
          tableComponents: [
            {
              compKey: "compKey11",
              labelName: "公司备注",
              codeField: "remark",
              changeCode: val => this.basecustClass(val),
              isRequire: false,
              isMust: true,
              disabled: this.$route.params.status === "edit" ? true : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey17",
              labelName: "信息来源",
              codeField: "infoChanDCode",
              textField: "infoChanName",
              isMust: true,
              isMul: false,
              disabled:true,
              component: () => import(   "@/components/crm/crmEjectWindows/crmSourceFrom/index" ),
              type: "propus",
              emitCode: (rowData, _this) => this.changeSource(rowData, _this)
            },
            {
              compKey: "compKey19",
              labelName: "客户来源",
              codeField: "custOriginCode",
              lookuptype: "LX860",
              isRequire: false,
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              isMust: true,
              component: () =>
                import("@/components/crm/lookupValue/lookupvalue")
            }
          ]
        },
        {
          isShow: true,
          tableComponents: [
            {
              compKey: "compKey27",
              labelName: "身份证1",
              codeField: "idCardPath",
              isMust: true,
              fileList: [],
              getVal:[],
              submitBtn: false,
              action: "/mp/file/crm/upload.do",
              limit:1,
              accepttype:'.jpg,.png',
              isautoupload: true,
              component: () => import("@/components/crm/crmEjectWindows/crmImgUpload/index"),//src\components\crm\crmEjectWindows\crmImgUpload\index.vue
              emitCode:this.getUploadFiles1,

            },
            {
              compKey: "compKey28",
              labelName: "身份证2",
              codeField: "driveCardPath",
              submitBtn: false,
              isMust: true,
              fileList: [],
              getVal:[],
              action: "/mp/file/crm/upload.do",
              limit:1,
              accepttype:'.jpg,.png',
              isautoupload: true,
              component: () => import("@/components/crm/crmEjectWindows/crmImgUpload/index"),
              emitCode:this.getUploadFiles2,

            },
            {
              compKey: "compKey29",
              labelName: "行驶证",
              codeField: "drivingCardPath",
              isMust: true,
              submitBtn: false,
              fileList: [],
              getVal:[],
              limit:1,
              accepttype:'.jpg,.png',
              action: "/mp/file/crm/upload.do",
              isautoupload: true,
              isUpload: true,
              component: () => import("@/components/crm/crmEjectWindows/crmImgUpload/index"),
              emitCode:this.getUploadFiles3,
            },
            // {
            //   compKey: "compKey27",
            //   labelName: "身份证",
            //   codeField: "idCardPath",
            //   submitBtn: false,
            //   isMust: true,
            //   fileList: [],
            //   getVal:[],
            //   limit:1,
            //   buttonText: "选择文件1",
            //   action: "/mp/file/crm/upload.do",
            //   isautoupload: true,
            //   component: () => import("@/components/crm/EjectWindows/UpLoad"),
            //   emitCode:this.getUploadFiles1,
            //   delFiles:this.getRemovedFiles1
            // },
            // {
            //   compKey: "compKey28",
            //   labelName: "驾驶证",
            //   codeField: "driveCardPath",
            //   submitBtn: false,
            //   isMust: true,
            //   fileList: [],
            //   getVal:[],
            //   limit:1,
            //   action: "/mp/file/crm/upload.do",
            //   isautoupload: true,
            //   buttonText: "选择文件2",
            //   component: () => import("@/components/crm/EjectWindows/UpLoad"),
            //   emitCode:this.getUploadFiles2,
            //   delFiles:this.getRemovedFiles2
            // },
            // {
            //   compKey: "compKey29",
            //   labelName: "行驶证",
            //   codeField: "drivingCardPath",
            //   submitBtn: false,
            //   isMust: true,
            //   fileList: [],
            //   getVal:[],
            //   limit:1,
            //   buttonText: "选择文件3",
            //   action: "/mp/file/crm/upload.do",
            //   isautoupload: true,
            //   component: () => import("@/components/crm/EjectWindows/UpLoad"),
            //   emitCode:this.getUploadFiles3,
            //   delFiles:this.getRemovedFiles3
            // }
          ]
        },
        // 联系信息   4
        {
          title: "联系信息",
          tableComponents: [
            {
              compKey: "compKey13",
              labelName: "公司电话",
              codeField: "phone",
              isRequire: true,
              validrule: {
                noRequire: false,
                isformat: /^((0\d{2,3}-\d{7,8})|(1(3|4|5|6|7|8|9)\d{9}))$/
              },
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey14",
              labelName: "官方微信号",
              codeField: "openId",
              isRequire: true,
              validrule: {
                noRequire: true,
                isformat: /^[a-zA-Z\d_]{5,}$/
              },
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey15",
              labelName: "官网",
              codeField: "webSite",
              isRequire: false,
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey16",
              labelName: "电子邮箱",
              codeField: "email",
              isRequire: true,
              validrule: {
                noRequire: true,
                isformat: /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/
              },
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey17",
              labelName: "传真号码",
              codeField: "faxTel",
              isRequire: true,
              validrule: {
                noRequire: true,
                isformat: /^0\d{2,3}-\d{7,8}$/
              },
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey14",
              labelName: "银行卡号",
              codeField: "invAccount",
              disabled:
                this.$route.params.status == "edit" &&
                this.$route.params.isCarowner == "是"
                  ? true
                  : false,
              component: () => import("@/components/crm/textbox/crmTextInput")
            },
            {
              compKey: "compKey16",
              labelName: "开户行",
              codeField: "invBank",
              textField: "invBankName",
              lookuptype: "LX829",
              component: () =>
                import("@/components/crm/lookupValue/lookupvalue")
            },
            {
              compKey: "compKey21",
              labelName: "邮政编码",
              codeField: "addrZip",
              isRequire: true,
              validrule: {
                noRequire: true,
                isformat: /[1-9]\d{5}(?!\d)/
              },
              isMust: true,
              component: () => import("@/components/crm/textbox/crmTextInput")
            }
          ]
        }
      ],
      formSubmitButton: [
        {
          compKey: "buttonKey1",
          text: "保存",
          size: "small",
          type: "",
          clickEvent: () => this.save(),
          isShow: true
        }
      ],
      // 标题
      textMap: {
        edit: "变更人车关系",
        add: "变更人车关系"
      },
      formField: {
        uid: "",
        provinceId: "",
        cityId: "",
        countyId:"",
        custName: "",
        custFullName: "",
        credNo: "",
        principalName: "",
        legalPhone: "",
        legalCredNo: "",
        addrProvince: "",
        addrCity: "",
        addrCounty: "",
        addrStreet:"",
        provinceName: "",
        cityName: "",
        countyName: "",
        compOrgscaleCode: "",
        compKindCode: "",
        remark:"",

        custOriginCode: "",
        custSourceName:"",
        infoChanDCode:"",
        infoChanName:"",
        webSize: "",
        compTel: "",
        webchat: "",
        openId:"",
        email: "",
        faxTel: "",
        custNo: "",
        dlrCustNo: "",
        phone: "",
        relationName: "",
        invAccount: "",
        invBank: "",
        invBankName: "",
        addrZip: "",
        webSite: "",
        legalName: "",
        legalPhone: "",
        legalCredNo: "",
        infoChanMCode:"",
        cantactWayCode:"",
      },
      saveformField: {
        uid: "",
        provinceId: "",
        cityId: "",
        countyId:"",
        addrCounty:"",
        custName: "",
        custFullName: "",
        credNo: "",
        principalName: "",
        legalPhone: "",
        legalCredNo: "",
        addrProvince: "",
        addrCity: "",
        addrCounty: "",
        addrStreet:"",
        compOrgscaleCode: "",
        compKindCode: "",
        remark:"",

        custOriginCode: "",
        infoChanDCode:"",
        webSize: "",
        compTel: "",
        webchat: "",
        email: "",
        faxTel: "",
        custNo: "",
        dlrCustNo: "",
        phone: "",
        relationName: "",
        invAccount: "",
        invBank: "",
        addrZip: "",
        legalName: "",
        legalPhone: "",
        legalCredNo: "",
        infoChanMCode:"",
      },
      dlrCustNo:this.$route.params.dlrCustNo,
      idCardPath:"null",
      driveCardPath:"null",
      drivingCardPath:"null",
      bcStatus:this.$route.params.status,
      bczz:Object
    };
  },
  mounted() {
    // this.State = this.$route.params.status;
    this.$nextTick(() => {
      if(this.$route.params.hZZ!=undefined)
      {
        this.bczz=this.$route.params.hZZ;
      }
      this.initdata();
    });
  },
  methods: {
    //信息来源change
    changeSource(rowData, _this) {
      let results = rowData[0];
      this.formField.infoChanDCode = results.infoChanDCode;
      this.formField.infoChanMCode = results.infoChanMCode;
    },
    // 查询
    query(api, row, params,num) {
      let that = this;
      let queryObj = {
        type: "query",
        apiConfig: api,
        apiServices: [
          {
            apiQueryRow: row
          }
        ],
        variables: {
          dataInfo: params
        }
      };
      var paramD = that.$getParams(queryObj);
      requestAPI(paramD).then(response => {
        if (response.data[queryObj.apiConfig.ServiceCode].result == "1") {
          let results = response.data[queryObj.apiConfig.ServiceCode].rows[0];
          for (let key in this.formField) {
            if (results.hasOwnProperty(key)) {
              this.formField[key] = results[key];
            }
          }
          let list1=[]
          let list2=[]
          let list3=[]
          list1[0]={}
          list2[0]={}
          list3[0]={}
          if(num==1){
            if(results.idCardPath&&results.idCardPath!="null")
            {
              list1[0].name=results.idCardPath.split('/')[results.idCardPath.split('/').length-1]
              list1[0].url=results.idCardPath
              that.idCardPath = results.idCardPath;
              that.infoComponents[4].tableComponents[0].getVal = list1;
            }
            if(results.driveCardPath&&results.driveCardPath!="null")
            {
              list2[0].name=results.driveCardPath.split('/')[results.driveCardPath.split('/').length-1]
              list2[0].url=results.driveCardPath
              that.driveCardPath = results.driveCardPath;
              that.infoComponents[4].tableComponents[1].getVal = list2;
            }
            if(results.drivingCardPath&&results.drivingCardPath!="null")
            {
              list3[0].name=results.drivingCardPath.split('/')[results.drivingCardPath.split('/').length-1]
              list3[0].url=results.drivingCardPath
              that.drivingCardPath = results.drivingCardPath;
              that.infoComponents[4].tableComponents[2].getVal = list3;
            }
          }
        } else {
          that.$crmcf.showMessages(
            that,
            "error",
            response.data[queryObj.apiConfig.ServiceCode].msg
          );
        }
      });
    },
    initdata() {
      if (this.$route.params.status == "edit") {
        let params = {};
        // params.custNo = this.$route.params.custNo;
        params.dlrCustNo = this.$route.params.dlrCustNo;
        // 基本信息
        let formField1 = [
          "uid",
          "custName",
          "custFullName",
          "genderCode",
          "provinceId",
          "addrProvince",
          "addrCity",
          "addrCounty",
          "cityId",
          "countyId",
          "nationCode",
          "credTypeCode",
          "principalName",
          "credNo",
          "addrStreet",
          "legalName",
          "legalPhone",
          "legalCredNo",
          "compOrgscaleCode",
          "compKindCode",
          "custOriginCode",
          "infoChanDCode",
          "infoChanName",
          "custSourceName",
          "remark",
          "idCardPath",
          "driveCardPath",
          "drivingCardPath",
          "infoChanMCode",
          "cantactWayCode"
        ];
        this.query(
          crmApis.custViewCustBaseInfoQueryFindAll,
          formField1,
          params,
          1
        );
        // 联系信息
        let formField2 = [
          "phone",
          "backupPhone",
          "homeTel",
          "officeTel",
          "qq",
          "openId", //微信
          "email",
          "convTimeCode",
          "contactTypeCode",
          "faxTel",
          "invAccount",
          "invBank",
          "invBankName",
          "webSite",
          "addrZip"
        ];
        this.query(crmApis.custViewContactWayQueryFindAll, formField2, params);
      }
      if(this.$route.params.isCarowner=="是")
      {
        this.infoComponents[4].isShow=true;
      }else{
        this.infoComponents[4].isShow=false;
      }
    },
    //保存
    save() {
      // validpopup  弹窗  validpage 页面
      let that=this;
      that.$utils.validataMoth(that, "crmpage",'','ref2');
      that.$utils.validataMoth(that, "crmpage",'','ref1');
      var html=""
      let vaild = true;
      let reg = that.$crmcf.crmRegExp("name")
      let reg1 = that.$crmcf.crmRegExp("tel")
      let reg2 = that.$crmcf.crmRegExp("telOrphone")
      let reg3 = that.$crmcf.crmRegExp("chnAndEn")
      let reg4 = that.$crmcf.crmRegExp("zip")
      let reg5 = that.$crmcf.crmRegExp("idCard")
      let reg6 = that.$crmcf.crmRegExp("email")
      let reg7 = that.$crmcf.crmRegExp("weChat")
      let reg8 = that.$crmcf.crmRegExp("QQ")
      if(!that.formField.custName)
      {
        html = html + `<div class="sys-alertDiv">请输入公司简称</div>`
      }else{
        var temp = 0;
        for (var i = 0; i < that.formField.custName.length; i++) {
          if (/[\u4e00-\u9fa5]/.test(that.formField.custName[i])) {
            temp += 2;
          } else {
            temp++;
          }
        }
        if (temp > 50) {
          html = html + `<div class="sys-alertDiv">公司简称不能超过50个字符</div>`;
        }
      }
      if(!that.formField.custFullName)
      {
        html = html + `<div class="sys-alertDiv">请输入公司全称</div>`
      }else{
        var temp = 0;
        for (var i = 0; i < that.formField.custFullName.length; i++) {
          if (/[\u4e00-\u9fa5]/.test(that.formField.custFullName[i])) {
            temp += 2;
          } else {
            temp++;
          }
        }
        if (temp > 200) {
          html = html + `<div class="sys-alertDiv">公司全称不能超过200个字符</div>`;
        }
      }
      if(that.formField.legalName)
      {
        var temp = 0;
        for (var i = 0; i < that.formField.legalName.length; i++) {
          if (/[\u4e00-\u9fa5]/.test(that.formField.legalName[i])) {
            temp += 2;
          } else {
            temp++;
          }
        }
        if (temp > 50) {
          html = html + `<div class="sys-alertDiv">法人名称不能超过50个字符</div>`;
        }
      }
      if(that.formField.legalPhone){
        if (!reg2.test(that.formField.legalPhone))
        {
          html = html + `<div class="sys-alertDiv">法人电话（手机或座机）格式不正确</div>`
        }
      }
      if (that.formField.legalCredNo) {
        if (!reg5.test(that.formField.legalCredNo)) {
          html = html + `<div class="sys-alertDiv">法人身份证请输入18位证件号</div>`;
        }
      }
      if(that.$route.params.status == "edit" && that.$route.params.isCarowner == "是"){

      }else {
        if (!that.formField.provinceId) {
          html = html + `<div class="sys-alertDiv">请选择省份</div>`;
        }
        if (!that.formField.cityId) {
          html = html + `<div class="sys-alertDiv">请选择城市</div>`;
        }
      }
      if(!that.formField.phone){
        html = html + `<div class="sys-alertDiv">请输入公司电话</div>`
      }else{
        if (!reg2.test(that.formField.phone))
        {
          html = html + `<div class="sys-alertDiv">公司电话（手机或座机）格式不正确</div>`
        }
      }
      if(that.formField.openId)
      {
        if (!reg7.test(that.formField.openId))
        {
          html = html + `<div class="sys-alertDiv">请输入5位以上，数字或字母或下划线组成的微信号</div>`
        }
      }
      if(that.formField.addrZip)
      {
        if (!reg4.test(that.formField.addrZip))
        {
          html = html + `<div class="sys-alertDiv">邮政编码格式不正确</div>`
        }
      }
      if(that.formField.email)
      {
        if (!reg6.test(that.formField.email))
        {
          html = html + `<div class="sys-alertDiv">电子邮箱格式不正确</div>`
        }
      }
      if (html != '') {
        this.$crmcf.showMessages(this, 'error', html, true)
        return;
      }
      //this.$utils.validataMoth(this, "validpopup");
      if (vaild) {
        this.saveForm();
      }
    },
    saveForm() {
      //保存表单
      // this.$refs.upLoad.$refs.compKey27[0].submitUpload();
      // this.$refs.upLoad.$refs.compKey28[0].submitUpload();
      // this.$refs.upLoad.$refs.compKey29[0].submitUpload();
      let that = this;
      this.formField.custClassCode = "1";
      this.formField.dlrCustNo = this.dlrCustNo;
      let custModifyScence = "";

      let results = this.formField;
      for (let key in this.saveformField) {
        if (results.hasOwnProperty(key)) {
          this.saveformField[key] = results[key];
        }
      }
      this.saveformField.dlrCustNo = this.dlrCustNo;
      this.saveformField.addrProvince = this.formField.provinceName;
      this.saveformField.addrCity = this.formField.cityName;
      this.saveformField.addrCounty = this.formField.countyName;
      this.saveformField.driverTypeCode = this.formField.driveTypeCode;
      this.saveformField.custClassCode = "1";
      this.saveformField.webSize = this.formField.webSite;
      this.saveformField.webchat=this.formField.openId;
      this.saveformField.custFullName =
        this.saveformField.custFullName == ""
          ? this.saveformField.custName
          : this.saveformField.custFullName;

      if (this.bcStatus == "edit") {
        custModifyScence = "303";
      } else if (this.bcStatus == "add") {
        custModifyScence = "301";
      }
      let queryObj = {
        // api配置
        type: "mutation",
        apiConfig: crmApis.createdOneIdMutationSaveCust, //客户信息-修改客户信息
        //条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          //当前中台使用的名称有dataInfo、info，具体查看API文档
          dataInfo: {
            custModifyScence: custModifyScence, //场景编码--修改客户信息
            custInfo: this.saveformField
          }
        }
      };

      //转换了中台请求格式数据
      var paramD = that.$getParams(queryObj);
      // 调用中台API方法（可复用）
      requestAPI(paramD).then(response => {
        if (
          response.data[queryObj.apiConfig.ServiceCode].result == "1"
          // &&response.data[queryObj.apiConfig.ServiceCode].rows != ""
        ) {
          that.uploadFiles('1',that.idCardPath)
          that.uploadFiles('2',that.driveCardPath)
          that.uploadFiles('3',that.drivingCardPath)
          that.$crmcf.showMessages(that, "success", "保存成功！");
          that.$crmcf.crmcloseView(that);
          that.bczz.$refs.multipleTable.queryTable()
        } else {
          that.$crmcf.showMessages(
            that,
            "error",
            response.data[queryObj.apiConfig.ServiceCode].msg
          );
        }
      });
    },
    // 联动
    citychange(val) {
      let that = this;
      that.District.pcode = val;
      if (that.$refs.district == undefined) {
      } else {
        that.$refs.district.getData();
      }
    },
     //附件上传成功回调
    getUploadFiles1(list){
      if(list.length>0){
        for(var i=0;i<list.length;i++){
          this.idCardPath=list[i].path
        }
      }else {
        this.idCardPath=''
      }

    },
    getUploadFiles2(list){
      if(list.length>0){
        for(var i=0;i<list.length;i++){
          this.driveCardPath=list[i].path
        }
      }else {
        this.driveCardPath=''
      }
    },
    getUploadFiles3(list){
      debugger
      if(list.length>0){
        for(var i=0;i<list.length;i++){
          this.drivingCardPath=list[i].path
        }
      }else {
        this.drivingCardPath=''
      }
    },
    //移除文件列表
    getRemovedFiles1(list){
      this.idCardPath="null"
    },
    getRemovedFiles2(list){
      this.driveCardPath="null"
    },
    getRemovedFiles3(list){
      this.drivingCardPath="null"
    },
    //附件上传
    uploadFiles(type,path){
      let that=this;
      let queryObj = {
        // api配置
        type: "mutation",
        apiConfig: crmApis.mdmDlrCustInfoMutationUploadImg,
        // 需要调用的API服务配置
        apiServices: [{
            //表格中台返回网格的字段
            apiQueryRow:[]
        }],
        //条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          //当前中台使用的名称有dataInfo、info，具体查看API文档
          dataInfo: {
            dlrCustNo:that.dlrCustNo,
            idCardPath:path,
            credTypeCode:type
          }
        }
      }
      //转换了中台请求格式数据
      var paramD = that.$getParams(queryObj);
      // 调用中台API方法（可复用）
      requestAPI(paramD).then(response =>{
        if(
          response.data[queryObj.apiConfig.ServiceCode].result === "1"
          //&&response.data[queryObj.apiConfig.ServiceCode].rows!=""
          ){

          }else{
            // that.$crmcf.showMessages(that,'error',response.data[queryObj.apiConfig.ServiceCode].msg)
          }
      })
    },
  }
};
</script>
<style scoped>
.choosefile {
  float: left;
  text-align: left;
}
</style>
